#ifndef _CRF_CLASSIFIER_H
#define _CRF_CLASSIFIER_H
/*
** Classification algorithms for svms
*/

#include "param.h"
#include "sparse_array.h"
#include "data.h"

#include <iostream>
#include <vector>

#include <boost/shared_ptr.hpp>

struct Evaluation
{
    Evaluation() : tp(0), fp(0), tn(0), fn(0) {}
    ~Evaluation() { /*delete confusion;*/ }

    int tp, fp, tn, fn;
//    int p_correct[5];
//    std::map<int,int> cls_correct;
//    std::map<int,int> cls_total;
//    int *confusion;
//    int sequence_correct;
//    std::vector<int> labels;
};
typedef boost::shared_ptr<Evaluation> EvaluationPtr;

////////////////////////////////////////////////////////////////////////////////
// Classifier
////////////////////////////////////////////////////////////////////////////////
class CRFClassifier
{
public:
    CRFClassifier(boost::shared_array<double> alpha, GPParameterPtr param);

    std::vector<unsigned int> classify(EventPtr v);
    EvaluationPtr evaluate(EventsPtr data, GPParameterPtr param);
    std::vector<std::vector<std::pair<double,int> > >  
        distribution(const Clique &v);

    std::vector<unsigned int> beam(const std::vector<SparseArrayPtr> &sequence);
    std::vector<unsigned int> viterbi(EventPtr v, bool print=false);

protected:
    boost::shared_array<double> m_alpha;
    EventsPtr m_data;
    ParameterPtr m_param;
};

#endif // _CRF_CLASSIFIER_H
